
/* Generated by Interface Builder */

#import "DefaultMgr.h"
#import <stdio.h>
#import "strings.h"
#import <appkit/Form.h>

@implementation DefaultMgr

- setFloatForm:anObject
{
    floatForm = anObject;
    return self;
}

- setStringForm:anObject
{
    stringForm = anObject;
    return self;
}

- setIntegerForm:anObject
{
    integerForm = anObject;
    return self;
}

- writeDefaults:sender
{
NXTypedStream *tStream;
	myFloat = [floatForm floatValueAt:0];
	myInt = [integerForm intValueAt:0];
	printf("b %s\n", myString);
	strcpy(myString, [stringForm stringValueAt:0]);
	printf("a %s\n", myString);
	tStream = NXOpenTypedStreamForFile("typedStream", NX_WRITEONLY);
	if (tStream) {
		// NXWriteTypes(tStream, "if[100c]", &myInt, &myFloat, myString);
		// NXWriteTypes(tStream, "if[100c]", &myInt, &myFloat, &myString);
		NXWriteTypes(tStream, "if", &myInt, &myFloat);
		NXWriteArray(tStream, "c", 100, myString);
		NXCloseTypedStream(tStream);
	} else {
	    printf("No typed stream\n");
	}
    return self;
}

- readDefaults:sender
{
NXTypedStream *tStream;
	tStream = NXOpenTypedStreamForFile("typedStream", NX_READONLY);
	// NXReadTypes(tStream, "if[100c]", &myInt, &myFloat, myString);
	// NXReadTypes(tStream, "if[100c]", &myInt, &myFloat, &myString);
	NXReadTypes(tStream, "if", &myInt, &myFloat);
	NXReadArray(tStream, "c", 100, myString);
	[integerForm setIntValue:myInt];
	[floatForm setFloatValue:myFloat];
	[stringForm setStringValue:myString];
	NXCloseTypedStream(tStream);
    return self;
}


@end
